/**
 * Copyright (c) 2016-2019 九点科技 All rights reserved.
 *
 * http://www.9dyun.cn
 *
 * 版权所有，侵权必究！
 */
package com.dian.modules.sale.controller;

import java.util.Map;
import java.util.List;
import com.dian.common.annotation.SysLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import oracle.jdbc.proxy.annotation.Post;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.dian.common.controller.AbstractController;
import com.dian.modules.sale.entity.GaugeSheetEntity;
import com.dian.modules.sale.service.GaugeSheetService;
import com.dian.modules.sale.vo.GaugeSheetExportVO;
import com.dian.common.utils.PageUtils;
import com.dian.common.utils.R;


/**
 * 量尺单
 *
 * @author xiaolai
 * @email xiaolai@9dyun.cn
 * @date 2019-06-21 10:19:58
 */
@RestController
@Api("量尺单接口")
@RequestMapping("sale/gaugeSheet")
public class GaugeSheetController extends AbstractController{
    @Autowired
    private GaugeSheetService gaugeSheetService;

    /**
     * 量尺单列表
     */
    @SysLog("量尺单列表")
    @GetMapping("/list")
    @ApiOperation("量尺单列表")
    @RequiresPermissions("sale:gaugeSheet:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = gaugeSheetService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 量尺单信息
     */
    @SysLog("量尺单信息")
    @ApiOperation("量尺单信息")
    @GetMapping("/info/{id}")
    @RequiresPermissions("sale:gaugeSheet:info")
    public R info(@PathVariable("id") Long id){
        GaugeSheetEntity gaugeSheet = gaugeSheetService.getInfo(id);
        return R.ok().put(gaugeSheet);
    }

    /**
     * 量尺单保存
     */
    @SysLog("量尺单保存")
    @ApiOperation("量尺单保存")
    @PostMapping("/save")
    @RequiresPermissions("sale:GaugeSheet:save")
    public R save(@RequestBody GaugeSheetEntity gaugeSheet){

		gaugeSheetService.saveInfo(gaugeSheet);

        return R.ok();
    }

    /**
     * 量尺单修改
     */
    @SysLog("量尺单修改")
    @ApiOperation("量尺单修改")
    @PostMapping("/update")
    @RequiresPermissions("sale:gaugeSheet:update")
    public R update(@RequestBody GaugeSheetEntity gaugeSheet){

		gaugeSheetService.updateInfo(gaugeSheet);

        return R.ok();
    }

    /**
     * 量尺单删除
     */
    @SysLog("量尺单删除")
    @ApiOperation("量尺单删除")
    @PostMapping("/delete")
    @RequiresPermissions("sale:gaugeSheet:delete")
    public R delete(@RequestBody Long[] ids){

		gaugeSheetService.deleteInfo(ids);

        return R.ok();
    }


    /**
     * 量尺单审核
     */
    @SysLog("量尺单审核")
    @ApiOperation("量尺单审核")
    @GetMapping("/check/{id}")
    @RequiresPermissions("sale:gaugeSheet:check")
    public R check(@PathVariable("id") Long id){

        gaugeSheetService.checkInfo(id);

        return R.ok();
    }


    /**
     * 量尺单导出
     */
    @SysLog("量尺单导出")
    @ApiOperation("量尺单导出")
    @GetMapping("/export")
    @RequiresPermissions("sale:gaugeSheet:export")
    public void export(@RequestParam Map<String, Object> params){

        List<GaugeSheetExportVO> list = gaugeSheetService.exportList(params);

        exportExcel(list,"量尺单","量尺单",GaugeSheetExportVO.class,"量尺单.xls");
    }

}
